﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace AndreySmirnov.BLToolkitUtils.VSPackage.UI
{
    public class NegativeBoolConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is bool && (targetType == typeof(bool) || (targetType == typeof(bool?))))
            {
                var val = (bool)value;
                return !val;
            }
            return DependencyProperty.UnsetValue;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is bool && (targetType == typeof(bool) || (targetType == typeof(bool?))))
            {
                var val = (bool)value;
                return !val;
            }
            return DependencyProperty.UnsetValue;
        }
    }
}